﻿using FactoryClsssLib.Examples2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FactoryClsssLib.Factory
{
    /// <summary>
    /// 颜色工厂
    /// </summary>
    public class ColorFactory : IAbstractFactory<IColor>
    {

        public override IColor getObject(string key)
        {
            if (key.Equals("RED"))
            {
                return new Red();
            }
            else if (key.Equals("GREEN"))
            {
                return new Green();
            }
            else if (key.Equals("BLUE"))
            {
                return new Blue();
            }
            return null;
        }

        public IColor GetObject(string key)
        {
            if (key.Equals("RED"))
            {
                return new Red();
            }
            else if (key.Equals("GREEN"))
            {
                return new Green();
            }
            else if (key.Equals("BLUE"))
            {
                return new Blue();
            }
            return null;
        }
    }
}
